package com.jqq.homework;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author 姬倩倩
 * @version 1.0
 */
@SuppressWarnings({"all"})
public class Homework01 {
    public static void main(String[] args) {
        List list = new ArrayList();
        list.add(new News("新冠确诊病例超干万，" +
                "数百万印度教信徒赴恒河“圣浴”引民众担忧"));
        list.add(new News("男子突然想起2个月前钓的鱼" +
                "还在网兜里，捞起一看赶紧放生"));
        for (int i = list.size()-1; i >= 0; i--) {
            Object o = list.get(i);
            News news = (News) o;
            if(news.getTitle().length() > 15){
                news.setTitle(news.getTitle().substring(0,15)+"...");
            }
            System.out.println(news.getTitle());
        }

    }
}
class News{
    private String title;
    private String content;

    public News(String title) {
        this.title = title;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    @Override
    public String toString() {
        return "News{" +
                "title='" + title + '\'' +
                '}';
    }
}